using System.Collections.Generic;
using Crocodile.LangUtils;
using JetBrains.Annotations;



namespace Crocodile.CsharpLanguage.Tree
{
    public class CsMultyRandomExpression : CsExpression
    {
        private readonly List<string> lines =
            new List<string>();


        /// <summary>
        /// Adds a line to the expression.
        /// </summary>
        /// <param name="line">line to add.</param>
        public void AddLine([NotNull] string line)
        {
            lines.Add(line);
        }


        /// <summary>
        /// Adds a line (with insets) to the expression.
        /// </summary>
        /// <param name="template">line template.</param>
        /// <param name="args">parameters for the template.</param>
        public void AddLine([NotNull] string template,params object[] args)
        {
            string line = string.Format(template,args);
            AddLine(line);
        }


        public override string[] Text
        {
            get { return lines.ToArray(); }
        }


        public override string ToString()
        {
            return lines.JoinAll(s => s,delimiter: "\n",empty: "{}");
        }
    }
}